<?php
/**
 * 任务日志ajax类
 */

quanli_require('module/base/system/taskLog.class.php');

class ajax_taskLog {

    public function execute(){

        if (isset($_REQUEST['operFlg'])) {

            switch($_REQUEST['operFlg']){

                case 1://查询任务日志
                    $this->searchTaskLogList();
                    break;
                default:
                    returnJsonData('参数错误');
                    break;

            }

        }else{
            returnJsonData('参数错误');
        }
    }


    /*
     *查询日志信息
     *
     */
    private function searchTaskLogList(){

        global $G_PGLOB;

        //实例化日志
        $taskLog = new taskLog();

        //查询日志信息
        $taskLog_array = $taskLog->searchTaskLogList( $_REQUEST );

        //组织返回的数据
        $result_array = array(
            'page' => $_REQUEST['page'],
            'total' => $_REQUEST['count'],
            'rows' => array()
        );

        if($taskLog_array){
            foreach($taskLog_array as &$taskLog){
                if(!empty($result_array[0]->name) && !empty($result_array[0]->createTime)){
                    $result_array['rows'][] = array(
                        'cell' => array(
                            $taskLog['task_id'],
                            $taskLog['creator'],
                            $taskLog['level'],
                            $taskLog['createTime'],
                            $taskLog['name'],
                            $taskLog['message']
                        )
                    );
                }else{
                    $result_array['rows'][] = array(
                        'cell' => array(
                            $taskLog['task_id'],
                            $taskLog['creator'],
                            $taskLog['level'],
                            $taskLog['createTime'],
                            $taskLog['name'],
                            $taskLog['message']
                        )
                    );
                }
            }
        }

        echo json_encode($result_array);

    }


}